<table class="bordure">	
	<tbody id="machines_sort_<%= salle_id %>">
<% @machines.each do |machine| %>
<% machine_id = "machine_#{machine.id}" %>
  <tr id="tr_<%= machine_id %>">
  	<% if authenticated? %>
	    <td >
	    	<span style="cursor:move" class="handle_machine_<%= salle_id %>"><%= image_tag('dnd-move-linux.png', :alt =>"trier", :title => "Selectionner pour trier", :height =>"32px", :width =>"32px") %></span>
	    </td>
	<% end %>
    <td>
    	<% if machine.salle_id > 0%>
    		<img id="information" src="/images/information.png" onmousemove="suivre_souris(event);" onmouseout="$('info_bulle_machine').hide();$('info_bulle_machine').innerHTML =''" onmouseover="$('info_bulle_machine').show();<%= remote_function(
  				:update =>"info_bulle_machine", :before => "afficherLoadingInfoBulle()", :url => { :action => :listInfoMachine, :controller => :machines, :id_machine => machine.id })%>" />
  		<% end %>
    </td>

    <td classe="bordure">
		<span id="span_<%= machine_id %>" class="machine" <% if authenticated? %>style="cursor:move"<% end %>>
			<%= image_tag('computer.png', :alt =>"Machine", :height =>"16px", :width =>"16px") %>&nbsp;&nbsp;<strong><%=h machine.nom_machine %></strong><br />
		</span>
		<em><%=h machine.adresse_ip %></em>
    </td>
    <td classe="bordure">
 	
	    	<%= image_tag('loading.gif', :id => "loading_ping_machine_"+machine.id.to_s, :style => "display:none", :alt =>"chargement", :height =>"20px", :width =>"20px" )%>
	    	<div id="result_ping_machine_ok_<%= machine.id.to_s %>" <% if machine.ping != 1 or machine.salle_id == 0 %>style="display:none" <% end %>>
	    		<%= link_to_remote image_tag('connect.png', :alt => 'connect', :title => 'Machine connecté - faire un ping'), 
		    		#:update => "result_ping_machine_"+machine.id.to_s, 
		    		:url => { :controller => :machines, :action => "ping", :adresse_ip => machine.adresse_ip,:id => machine.id },
		    		:before => "$('loading_ping_machine_"+machine.id.to_s+"').show();$('result_ping_machine_ok_"+machine.id.to_s+"').hide()",
		    		:script => true,
		    		:complete => "$('loading_ping_machine_"+machine.id.to_s+"').hide()"    		 
		    	%>
	    	</div>	
	    	<div id="result_ping_machine_nok_<%= machine.id.to_s %>" <% if machine.ping != 0 or machine.salle_id == 0%>style="display:none" <% end %>>
	    		<%= link_to_remote image_tag('disconnect.png', :alt => 'disconnect', :title => 'Machine déconnecté - faire un ping'), 
		    		#:update => "result_ping_machine_"+machine.id.to_s, 
		    		:url => { :controller => :machines, :action => "ping", :adresse_ip => machine.adresse_ip,:id => machine.id },
		    		:before => "$('loading_ping_machine_"+machine.id.to_s+"').show();$('result_ping_machine_nok_"+machine.id.to_s+"').hide()",
		    		:script => true,
		    		:complete => "$('loading_ping_machine_"+machine.id.to_s+"').hide()"    		 
		    	%>
	    	</div>
    </td>
    <td><span class="bouton"><%= link_to 'Voir', machine %></span></td>
    <% if authenticated? %>
    <td><span class="bouton"><%= link_to 'Modifier', edit_machine_path(machine) %></span></td>
    <td><span class="delete">
    	<%= link_to_remote 'Supprimer', 
	    			:url => {:controller => :machines, :action => :destroy}, 
	    			:with => "'id=#{machine.id}&salle_id=#{salle_id}'",
	    			#:update => 'table_salle_'+machine.salle_id.to_s,
	    			:before => "$('loading_delete_machine_"+machine.id.to_s+"').show()",
	    			:position => "bottom",
	    			:script => true, 
	    			:confirm => 'Etes-vous sur de supprimer cette machine ?'%>
	    </span>
	</td>
	<% end %>
	<td>
		<% if machine.salle_id > 0%>
			<div id="accident_machine_<%= machine.id.to_s %>">
				<% if Incident.getIncidentByMachine(machine.id) %>
					<%= link_to(image_tag('warning.png', :title => "Il y a un ou plusieurs accident(s) sur cette machine",:alt =>"incident", :height =>"16px", :width =>"16px" ), {:controller => :incidents, :action => 'showByMachine', :id => machine.id},:target => "_blank") %>
				<% end %>
			</div>
		<% end %>
	</td>
	<td>
		<%= image_tag('loading.gif', :id => "loading_delete_machine_"+machine.id.to_s, :style => "display:none", :alt =>"chargement", :height =>"20px", :width =>"20px")%>
	</td>
	<% if authenticated? %>
		<%= draggable_element("span_"+machine_id.to_s, :revert=>true, :ghosting => true, :onDrag => "function() { $('trash').show();$('info_bulle_machine').innerHTML =''; }",:change  => "function() { $('trash').show();$('info_bulle_machine').innerHTML =''; }") %>
	<% end %>
  </tr>
<% end %>
</tbody>
</table>
<% if authenticated? %>
	<%= sortable_element("machines_sort_"+salle_id.to_s, :tag => 'tr', :revert => true, :ghosting => false,:url=> {:controller=> "machines", :action=> 'sort', :salle_id => salle_id}, :handle => "handle_machine_"+salle_id.to_s) %>
<% end %>

